#!/bin/bash

# echo $#    #参数个数
# echo $*    #所有参数
# echo "========="

# xxx () {
#     echo $#
#     echo $*
#     echo $1 $2 $3
#     echo "hello"
#     echo "world"
#     return 10
# }

# xxx a b c
# val=$?

# echo "12-$val"

# echo "========="

# max () {
#     if [ $# -ne 2 ]; then
#         echo "参数个数不正确"
#     else
#         echo "参数个数正确"
#     fi

#     if [ $1 -gt $2 ]; then
#     return $1
#     else
#     return $2
#     fi
# }

# read -p "请输入两个数:" val1 val2
# max $val1 $val2
# val=$?
# echo "最大值是:$val"

echo "========="
get_sum () {
    echo "get_sum function"
    echo $* #所有参数
    i=$1
    sum=0
    while [ $i -le $2 ];do
        sum=`expr $sum + $i`
        i=`expr $i + 1`
    done
    echo $sum
}

get_sum 1 10
echo $?